//渲染列表
export function render(currentData, paddingSet, list) {
  const oFragment = document.createDocumentFragment(); //在内存中创建一个新的空白的文档片段
  currentData.forEach(item => {
    const oItem = document.createElement('div');
    oItem.className = 'list-item';
    oItem.innerText = item;
    oFragment.appendChild(oItem);
  });
  list.appendChild(oFragment);
  updatePaddingSet(paddingSet, list);
}

//更新列表渲染的数据
export function update(currentData, list) {
  const oItems = list.querySelectorAll('.list-item');
  oItems.forEach((item, index) => {
    item.innerText = currentData[index];
  })
}

//更新上下滚动的空白区域-缓冲区
export function updatePaddingSet(paddingSet, list) {
  for (let key in paddingSet) {
    list.style[key] = paddingSet[key] + 'px';
  }
}